package com.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.bean.GradeBean;
import com.project.bean.RoleBean;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface IRoleMapper extends BaseMapper<RoleBean> {

    public void addGradeList(@Param("roleId") int roleId,
                             @Param("gradeArray") int[] gradeArray);
    public List<GradeBean> findByRoleId(@Param("roleId") int roleId);
    public void updateGrade(@Param("roleId") int roleId,
                            @Param("gradeArray") int[] gradeArray);

    @Delete("delete from t_role_grade where fk_roleId=#{roleId};" +
    "delete from t_user_role where fk_roleId=#{roleId};" +
    "delete from t_role where pk_roleId=#{roleId};")
    public void del(int roleId);
}
